<!-- login 登录页面 -->
<template>
  <div class="rxn_container">
    <!-- <router-link to="/login" tag="el-button">测试tag属性</router-link> -->
    <div class="login_container">
      <div class="login_wrap">
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" @keydown.native.enter="submitForm('ruleForm')">
          <el-form-item label="账号" prop="username">
            <el-input type="text" v-model="ruleForm.username" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="密码" prop="password">
            <el-input type="password" v-model="ruleForm.password" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="" prop="code">
            <el-input placeholder="请输入内容" v-model="ruleForm.code">
              <template slot="append"><el-image src=""></el-image></template>
            </el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
            <el-button @click="registered('ruleForm')">注册</el-button>
            <el-button @click="resetForm('ruleForm')">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import { registered } from '@/api/user.js'
export default {
  data() {
    return {
      ruleForm: {
        username: '',
        password: '',
        code: ''
      },
      rules: {
        username: [{ required: true, message: '请输入账号', trigger: 'blur' }],
        password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
      }
    }
  },
  methods: {
    //点击 登录按钮
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log('submit!');
          this.$store.dispatch('VALID_LOGIN', this.ruleForm)
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    registered(formName) {
      registered(this.ruleForm)
    }
  },
  mounted() { }
}
</script>

<style scoped lang="scss">
// .rxn_container {
//   width: 100%;
//   height: 100vh;
//   background: black;
// }
.login_container {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  //登录卡片
  .login_wrap {
  }
}
</style>